package model.action;

import java.util.Date;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

import model.dao.BaiDAO;
import model.entities.Category;
import model.entities.Comment;
import model.entities.Post;


public class CommentAction extends ActionSupport{
    private Integer id;
    private int postId;
    private String content;
    private String name;
    private String email;
    private String phone;
    private boolean createCommentStatus;
    private Comment commentObj; 
    private List<Comment> listAllComment;
    public String createNewComment() {
        System.out.println("Content :" +content);
        BaiDAO baiDao = new BaiDAO();
        Post curPost = baiDao.getPostByID(postId);
        Date date = new Date();
        Comment comment = new Comment(curPost, date, content, name, email, phone);
        createCommentStatus = baiDao.createComment(comment);
        return SUCCESS;
    }
    public String allCommentByPostID() {
        BaiDAO baiDAO = new BaiDAO();
        listAllComment = baiDAO.listCommentByPostID(postId);
        return SUCCESS;
    }
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public int getPostId() {
        return postId;
    }
    public void setPostId(int postId) {
        this.postId = postId;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    public boolean isCreateCommentStatus() {
        return createCommentStatus;
    }
    public void setCreateCommentStatus(boolean createCommentStatus) {
        this.createCommentStatus = createCommentStatus;
    }
    public Comment getCommentObj() {
        return commentObj;
    }
    public void setCommentObj(Comment commentObj) {
        this.commentObj = commentObj;
    }
    public List<Comment> getListAllComment() {
        return listAllComment;
    }
    public void setListAllComment(List<Comment> listAllComment) {
        this.listAllComment = listAllComment;
    }
    
    
}
